var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, a) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var a in e)
              Object.prototype.hasOwnProperty.call(e, a) && (t[a] = e[a]);
          })(e, a);
      };
      return function (e, a) {
        function n() {
          this.constructor = e;
        }
        if ("function" != typeof a && null !== a)
          throw new TypeError(
            "Class extends value " + String(a) + " is not a constructor or null"
          );
        t(e, a),
          (e.prototype =
            null === a
              ? Object.create(a)
              : ((n.prototype = a.prototype), new n()));
      };
    })(),
  AXSubordinateView = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.onLoadActionDataFn = {
          caller: e,
          code: 2072,
          method: function (t) {
            0 == t.code
              ? (ToastView.toastView("设置成功！"),
                WebSocketService.send({ c: 1119, d: null }),
                Laya.stage.event("HomePageView", "cortege"),
                Laya.stage.event("GameMainView", "cortege"))
              : ToastView.toastView(t.msg);
          },
        }),
        (e.onLoadSuboardinateDataFn = {
          caller: e,
          code: 1119,
          method: function (t) {
            if (0 == t.code) {
              (e.list_suboardinate.visible = !0), (e.dataArr = t.list);
              var a,
                n = t.list;
              (e.dataSource = []), (e.fightNum = 0);
              for (var o = 0; o < n.length; o++) {
                n[o].pos >= 1 && (e.fightNum = o + 1);
                Utils.transform(n[o].roleType, "roleType");
                (a = {
                  lbl_suboard_index: {
                    text: Utils.dealTransAndLvl(n[o].roleType, n[o].lvl),
                  },
                  lbl_suboard_name: { text: n[o].name },
                  lbl_suboard_star: { text: e.dealSuboardStar(n[o].star) },
                  btn_suboard: { label: e.dealsuboardStateFn(n[o].pos) },
                  suboard_id: n[o].id,
                  pos: n[o].pos,
                }),
                  e.dataSource.push(a);
              }
              e.list_suboardinate.array = e.dataSource;
            } else ToastView.toastView(t.msg);
          },
        }),
        e.btn_suboard_back.on(Laya.Event.CLICK, e, e.onBackPreFn),
        e.btn_boarder_getfujiang.on(Laya.Event.CLICK, e, e.onGetFujiangAction),
        WebSocketService.addListener(e.onLoadSuboardinateDataFn, !0),
        WebSocketService.addListener(e.onLoadActionDataFn),
        (e.list_suboardinate.selectEnable = !0),
        (e.list_suboardinate.vScrollBarSkin = ""),
        e.list_suboardinate.on(Laya.Event.CLICK, e, e.onSuboardinateDidClickFn),
        (e.list_suboardinate.renderHandler = new Laya.Handler(e, e.updateItem)),
        e
      );
    }
    return (
      __extends(e, t),
      (e.openView = function () {
        return (
          null == this.fuJiangInstance && (this.fuJiangInstance = new e()),
          WebSocketService.send({ c: 1119, d: null }),
          (this.fuJiangInstance.list_suboardinate.visible = !1),
          this.fuJiangInstance
        );
      }),
      (e.prototype.dealSuboardStar = function (t) {
        var e = "";
        return t > 0 && (e = " (" + t + "星) "), e;
      }),
      (e.prototype.updateItem = function (t, e) {
        if (!(e > this.dataSource.length)) {
          var a = t.getChildByName("lbl_suboard_index"),
            n = t.getChildByName("lbl_suboard_name"),
            o = t.getChildByName("lbl_suboard_star"),
            r = t.getChildByName("btn_adjust_up"),
            i = t.getChildByName("btn_suboard"),
            s = this.dataArr[e].s,
            d = Dictionary.colorType[s];
          (n.color = d),
            (a.color = d),
            (o.color = d),
            (r.visible = !1),
            (i.gray = !0),
            this.dataArr[e].pos >= 1
              ? ((i.gray = !1), 0 == e || (this.fightNum, (r.visible = !0)))
              : this.dataArr[e].pos,
            1 == this.fightNum && (r.visible = !1);
        }
      }),
      (e.prototype.dealsuboardStateFn = function (t) {
        var e = parseInt(t);
        return e >= 1
          ? "休息"
          : -1 == e
          ? "不可出战"
          : 0 == e
          ? "出战"
          : void 0;
      }),
      (e.prototype.getCurrentSuboardState = function (t) {
        var e = parseInt(t);
        return e >= 1
          ? "已出战"
          : -1 == e
          ? "不可出战"
          : 0 == e
          ? "未出战"
          : void 0;
      }),
      (e.prototype.onSuboardinateDidClickFn = function (t) {
        if ("" != t.target.name) {
          this.dataArr[this.list_suboardinate.selectedIndex];
          var e = this.dataArr[this.list_suboardinate.selectedIndex].pos,
            a = this.dataArr[this.list_suboardinate.selectedIndex].id,
            n = parseInt(e);
          if ("btn_suboard" == t.target.name)
            n >= 1
              ? WebSocketService.send({ c: 2072, d: { id: a, act: 3 } })
              : 0 == n
              ? WebSocketService.send({ c: 2072, d: { id: a, act: 4 } })
              : -1 == n && ToastView.toastView("该副将不可出战");
          else if ("btn_adjust_down" == t.target.name)
            WebSocketService.send({ c: 2072, d: { id: a, act: 2 } });
          else if ("btn_adjust_up" == t.target.name)
            WebSocketService.send({ c: 2072, d: { id: a, act: 1 } });
          else {
            var o = this.dataArr[this.list_suboardinate.selectedIndex],
              r = AXSuboardinateDetailView.showSuboardView(o);
            r.pos(0, 35), Laya.stage.addChild(r);
          }
        }
      }),
      (e.prototype.onGetFujiangAction = function () {
        AXRecruitmentDialog.showRecruitmentOpen("1", "AXSubordinateView");
      }),
      (e.prototype.onBackPreFn = function () {
        this.removeSelf();
      }),
      (e.fuJiangInstance = null),
      e
    );
  })(ui.SuboardinateController.AXSubordinateViewUI);
